package com.longxiao.validator;


import java.util.LinkedHashMap;
import java.util.Map;

import com.longxiao.validator.handler.ValidHandler;
import com.longxiao.validator.handler.ValidNotBlankHander;
import com.longxiao.validator.handler.ValidNumberHandler;
import com.longxiao.validator.handler.ValidStringHandler;

/**
 * Created by houhongwei on 2017/5/16.
 */
public class Validator {

    static Map<String, ValidHandler> handlerMap = new LinkedHashMap<String, ValidHandler>();

    static {
        Validator.addHandler(ValidNotBlankHander.class.getSimpleName(), new ValidNotBlankHander());
        Validator.addHandler(ValidStringHandler.class.getSimpleName(), new ValidStringHandler());
        Validator.addHandler(ValidNumberHandler.class.getSimpleName(), new ValidNumberHandler());
    }

    public static void addHandler(String key, ValidHandler handler) {
        handlerMap.put(key, handler);
    }

    public static ValidHandler getHandler(String key) {
        return handlerMap.get(key);
    }



}
